<?php
namespace Crm\Table;

use Zend\Db\Sql\Select;
use Zend\Db\Sql\Where;

class OrganizationAddrTable extends AbstractTable
{

    protected $table = 'hy_organization_addr';

    protected $id = 'id';
    
    public function findAll()
    {
        $rowset = $this->select();
        $result = $rowset->toArray();
        return $result;
    }
    
    public function findAllByOrgId($id)
    {
        $rowset = $this->select(array(
            'org_id' => $id
        ));
        $result = $rowset->toArray();
        return $result;
    }
    
    public function create($data)
    {
        return $this->insert($data);
    }

    public function findOne($id)
    {
        $rowset = $this->select(array(
            $this->getId() => $id
        ));
        $row = $rowset->current();
        return $row;
    }

    public function updateById($data, $id)
    {
        return $this->update($data, array(
            $this->getId() => $id
        ));
    }

    public function remove($id)
    {
        return $this->delete(array(
            $this->getId() => $id
        ));
    }
}